import router from "./router"
import { getLocalToken } from "./utils/auth"

const whiteList = ['/login', '/404']
router.beforeEach((to, from, next) => {
  // to 去哪
  // from 从哪来
  // next 是否放行
  const token = getLocalToken()
  if (token) {
    next()
  } else {
    if (whiteList.includes(to.path)) {
      // 白名单内
      next()
    } else {
      next('/login')
    }
  }
})